class filehandler():
    """
    This class represents filehandling methods
    """
    def __init__(self, path):
        """
        Constructor.
        
        path -- path of files
        """
        'assert path'
        self.path = path
        self.artists={}
    
    def sortfiles(self):
        """
        sortfiles
        """
        import glob
        import re
        for filename in (glob.glob(self.path+r'\*.jpg')+glob.glob(self.path+r'\*.png')):
            artistname=(re.match('(.*)\\\\(.*)_.*',filename)).group(2)
            self.artists[artistname]=[filename] if artistname not in self.artists else self.artists[artistname]+[filename]
        return
if __name__ == "__main__":
    from sys import argv
    if 1 in argv:
        newclass=filehandler(argv[1])
    else:
        newclass=filehandler("g:\\music\\artists\\")
    newclass.sortfiles();
    for x in newclass.artists:
        print(x+'=>')
        for y in newclass.artists[x]:
            print("\t\t\t"+y)
